# -*- coding: utf-8 -*-
from dwjjCoreServerScripts.common import consts, logger
from dwjjCoreServerScripts.module import worldModule, playerModule, entityModule, ruleModule, redstoneModule

import mod.server.extraServerApi as serverApi
import apolloCommon.commonNetgameApi as netgameApi

ServerSystem = serverApi.GetServerSystemCls()


class ServerSys(ServerSystem):

    def __init__(self, namespace, systemName):
        logger.Suc("==== [" + consts.ServerSystemName + "] enable ====")
        super(ServerSys, self).__init__(namespace, systemName)
        self.Init()
        self.SetListener()

    def Destroy(self):
        logger.Suc("==== [" + consts.ServerSystemName + "] disable ====")

    def Init(self):
        self.worldModule = worldModule.WorldModule(self, netgameApi.GetModJsonConfigByName("dwjjCoreServerScripts", "configs/world.json"))
        self.playerModule = playerModule.PlayerModule(self, netgameApi.GetModJsonConfigByName("dwjjCoreServerScripts", "configs/player.json"))
        self.entityModule = entityModule.EntityModule(self, netgameApi.GetModJsonConfigByName("dwjjCoreServerScripts", "configs/entity.json"))
        self.ruleModule = ruleModule.RuleModule(self, netgameApi.GetModJsonConfigByName("dwjjCoreServerScripts", "configs/rule.json"))
        self.redstoneModule = redstoneModule.RedstoneModule(self, netgameApi.GetModJsonConfigByName("dwjjCoreServerScripts", "configs/redstone.json"))

    def SetListener(self):
        pass
